/**
 * Created by guiyongdong on 16/10/12.
 */

import  React, {Component} from 'react';
import  {
    View,
    Image,
    TouchableOpacity,
    WebView
} from 'react-native';

import NavigationBar from 'react-native-navbar';


export default class WebViewRN extends Component{

    _renderNavLeftButton(){
        return(
            <TouchableOpacity activeOpacity={0.8} onPress={this.gotoBack.bind(this)}>
                <View style={{flexDirection:'row',alignItems:'center',height:44,width:44}}>
                    <Image style={{width:20,height:20,marginLeft:5}} source={require('../resoure/main/backbutton_icon2.png')}/>
                </View>
            </TouchableOpacity>
        );
    }

    gotoBack(){
        var nav = global.nav;
        nav.pop();
    }

    render(){
        var url = this.props.url;
        return(
            <View style={{backgroundColor:'red',flex:1}}>
                <NavigationBar
                    tintColor='white'
                    statusBar={{style:'default'}}
                    leftButton={this._renderNavLeftButton()}
                />
                <WebView
                    style={{flex:1}}
                    source={{uri:url}}
                />
            </View>
        );
    }

}
